<template>
  <div class="public-head">
    <div class="public-head-nav">
      <div class="public-head-left">
        <h1 class="public-head-logo"><a href="javascript:;">
          <img src="/image/logo.png" alt="">
        </a></h1>
        <ul class="public-head-list">
          <li><a href="index.html" target="_blank">主页</a></li>
          <li class="public-head-hover">
            <a href="javascript:void(0);">我要投资</a>
            <!--二级导航-->
            <div class="two-title">
              <a href="javascript:;">优先类产品</a>
              <a href="javascript:;">散标类产品</a>
            </div>
          </li>
          <li><a href="JavaScript:;" @click="$router.push('/userCenter')">个人中心</a></li>
          <li><a href="javascript:;" target="_blank">信息披露</a></li>
          <li><a href="javascript:;" target="_blank">安全计划</a></li>
        </ul>
      </div>

      <div v-if="isLogin" class="public-head-right">
        <a href="javascript:;" @click="changeAccount">切换账号</a>
      </div>

      <div v-else class="public-head-right">
        <a href="javascript:;" @click="$router.push('/login')">登录</a>
        <a href="javascript:;" @click="$router.push('/')">注册</a>
      </div>

    </div>
  </div>
</template>

<script>
import Vue from "vue";

export default {
  name: "Header",
  data() {
    return {
      isLogin: sessionStorage.getItem("token")
    }
  },
  methods: {
    changeAccount() {
      Vue.axios.get("/user/logout").then(()=>{
        console.log("222222222222222")
        sessionStorage.removeItem("token")
        sessionStorage.removeItem("loginUser")

        this.$router.push("/login")
      })

    }
  }
}
</script>

<style scoped>

</style>